import React from 'react';
import { Card, Button, Checkbox, Form, Input, Space } from 'antd';
import LoginStyle from './Loginstyle.less';
import './Loginstyle.less';
import { addCanvas } from '@/hoc/index.js';
import { userLogin } from '@/api/login';
// umi常用的跳转路由方式
import { withRouter } from 'react-router-dom';

const onFinishFailed = (errorInfo: any) => {
  console.log('Failed:', errorInfo);
};

function index(props: any) {
  const { history } = props;
  const onFinish = (values: any) => {
    // userLogin(values).then((res)=>{
    //   console.log(res)
    // })
    sessionStorage.setItem('token', 'SDFGTFFDSSS');
    history.push('/');
  };
  return (
    <div className={LoginStyle.login}>
      <Card
        title="管理中心登录"
        className={LoginStyle.card}
        headStyle={{ textAlign: 'center', fontSize: '24px', fontWeight: 700 }}
        style={{ width: 400, color: '#fff' }}
        bordered={false}
      >
        <Form
          name="basic"
          style={{ maxWidth: 600 }}
          initialValues={{ remember: true }}
          onFinish={onFinish}
          onFinishFailed={onFinishFailed}
          autoComplete="off"
        >
          <Form.Item
            name="username"
            rules={[{ required: true, message: '请输入用户名' }]}
          >
            <Input />
          </Form.Item>

          <Form.Item
            name="password"
            rules={[{ required: true, message: '请输入密码' }]}
          >
            <Input.Password />
          </Form.Item>

          <Form.Item
            name="verify_codec"
            rules={[{ required: true, message: '请输入用户名' }]}
          >
            <Space direction="horizontal">
              <Input />
              <img className='img1'
                src="http://fangadmin.shbwyz.com/login/verfiy.html?t=1677244999358"
                alt=""
              />
            </Space>
          </Form.Item>

          {/* <Form.Item
            name="verify_codec"
            rules={[{ required: true, message: '请输入验证码' }]}
          >
            <Space direction="horizontal">
            <Input.Password />
            <img src="http://fangadmin.shbwyz.com/login/verfiy.html?t=1677244999358" alt="" />
            </Space>
          </Form.Item> */}

          <Form.Item>
            <Button type="primary" style={{ width: '100%' }} htmlType="submit">
              登录
            </Button>
          </Form.Item>
        </Form>
      </Card>
    </div>
  );
}

export default addCanvas(withRouter(index));
